package com.byit.Test.join;

/**
 * @ClassName main1
 * @Description 当A线程执行到了B线程的.join()方法时，A就会等待。等B线程都执行完，A才会执行。
 * @Author lxp
 * @Date 2018/10/8 0008
 **/
public class main1_Join {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName() + "主线程运行开始!");
        Thread1 mTh1 = new Thread1("A");
        Thread1 mTh2 = new Thread1("B");
        mTh1.start();
        mTh2.start();
        try {
            mTh1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        try {
            mTh2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "主线程运行结束!");

    }

}

